var vod_big_class = "30"
var last_page;
module.exports = {
  type: 'list',
  title: '向日葵->类型选择',
  actions: [
    {
      title: '推荐',
      onClick: async function () {
        vod_big_class = "30"
        this.refresh()
      }
    },
    {
      title: '国产自拍',
      onClick: async function () {
        vod_big_class = "10"
        last_page = null
        this.refresh()
      }
    },
    {
      title: '高清无码',
      onClick: async function () {
        vod_big_class = "1"
        this.refresh()
      }
    },
    {
      title: '剧情',
      onClick: async function () {
        vod_big_class = "29"
        this.refresh()
      }
    },
    {
      title: '外流视频',
      onClick: async function () {
        vod_big_class = "32"
        this.refresh()
      }
    },
    {
      title: 'AV欧美',
      onClick: async function () {
        vod_big_class = "16"
        this.refresh()
      }
    },
    {
      title: '网红主播',
      onClick: async function () {
        vod_big_class = "17"
        this.refresh()
      }
    },
  ],
  searchRoute: $route('list'),
  async fetch({
    args,
    page
  }) {
    var resp;
    if (page == null) {
      resp = await $http.get(`http://xrkjk3.com/api/videosort/${vod_big_class}?orderby=new&page=1&uuid=48cf2ce1d253e8ee&device=0`)
      last_page = resp.data.rescont.last_page
      console.log(resp.data)
    } else {
      if (page <= last_page) {
        //console.log(`http://xrkjk3.com/api/videosort/${vod_big_class}?orderby=new&page=${page || 1}&uuid=48cf2ce1d253e8ee&device=0`)
        resp = await $http.get(`http://xrkjk3.com/api/videosort/${vod_big_class}?orderby=new&page=${page || 1}&uuid=48cf2ce1d253e8ee&device=0`)
        //console.log(typeof last_page + last_page +"xiangmu2")

      } else if (page == last_page) {
        $ui.toast("最后一页了");
      } else {
        console.log(page + "超过已有数据 勿刷新！！！")
      }
    }
    if (resp != null) {
      var itmes =  resp.data.rescont.data.map(data => ({
        style: 'live',
        title: data.title,
        image: data.coverpath, 
        route: $route('xj/detail', {
          id: data.id,
          type: "xrk",
          detailimage: data.coverpath
        })
      }))
      return {
        nextPage: (page || 1) + 1,
        items: itmes
      }
    }
  },
}